plugins: VOsc/VOsc3 - fix crash with negative buffer numbers
[supercollider.git] / examples / research_and_tools / trochoid curve.scd
blobc0060f884e4fa52d792ed555c2f352cbb6ee0842
3 a = 1.0;
4 b = 1.8;
5 x = { |phi, a, b| a * phi - (b * sin(phi)) };
6 y = { |phi, a, b| a - (b * sin(phi + 0.5pi)) };
9 GUI.cocoa;      // use CocoaGUI (Mac OS X native)
10 GUI.swing;      // use SwingGUI (Java based GUI)
13                 var pen = GUI.pen;
14                 w = GUI.window.new("Trochoid", Rect(128, 64, 800, 400)).front;
15                 w.view.background_(Color.white);
16                 w.drawHook = {
17                         pen.strokeColor = Color.black;
18                         pen.moveTo(0 @ 150);
19                         ((0..900) / 50).do { |phi|
20                                 var x0 = x.(phi, a, b);
21                                 var y0 = y.(phi, a, b);
22                                 pen.lineTo((50 * x0) @ (50 * y0 + 150));
23                         };                      
25                         pen.stroke
26                 };
27                 w.refresh;
32 Tdef(\x, {
33         loop {
34                 ((0..100) / 25).do { |m|
35                         b = m;
36                         defer {w.refresh};
37                         0.1.wait
38                 }
39         }
40 }).play
44 // sonification of a trochoid
47 p = ProxySpace.push(s.boot); // enter
48 ~out.play;
51 ~out = {
52         SinOsc.ar(500).dup * ~modulation.kr(2) * 0.04
58 ~phi = {
59         LFSaw.kr(3).range(0, 2pi)
62 ~modulation = {
63         var x, y;
64         var a, b;
65         a = 1.0;
66         b = XLine.kr(0.1, 2, 30);
67         x = { |phi, a, b| a * phi - (b * sin(phi)) }.value(~phi.kr, a, b);
68         y = { |phi, a, b| a - (b * sin(phi + 0.5pi)) }.value(~phi.kr, a, b);
69         [x, y]
73 p.clear.pop; // exit